// 学jq之前敲得内容 用原生js写的
var ipt = document.getElementsByClassName('form')[0].children[0]
ipt.onclick = function () {
    if (this.value == '电视盒子') {
        this.value = ''
    }
    this.style.color = '#000000'
}
ipt.onblur = function () {
    if (this.value == '') {
        this.value = '电视盒子'
        this.style.color = '#999999'
    }
}
document.body.addEventListener('keyup', function (e) {
    e = e || window.event
    if (e.keyCode === 83) {
        ipt.focus()
        ipt.value = ''
        ipt.style.color = '#000000'
    }
})

var jd_container = document.getElementsByClassName('container')[0]
window.onload = function () {
    jd_container.style.display = 'block'
}

var del_btn = jd_container.getElementsByTagName('button')[0]
del_btn.onclick = function () {
    jd_container.style.display = 'none'
}

var search_mBox = document.getElementsByClassName('search_mBox')[0]
var elevator = document.getElementsByClassName('elevator')[0]
window.onscroll = function () {
    if (document.documentElement.scrollTop > 300) {
        search_mBox.style.display = 'block'
        move(search_mBox, 'height', 50)
        elevator.className = 'copy'
        move(elevator, 'top', 100)
    }
    if (document.documentElement.scrollTop <= 10) {
        search_mBox.style.display = 'none'
        search_mBox.style.height = 0 + 'px'
        elevator.style.top = 0 + 'px'
        elevator.className = 'elevator'
        move(elevator, 'top', 0)
    }
}

var ss_img = document.getElementsByClassName('ss_img')[0]
ss_img.onmouseenter = function () {
    move(ss_img, 'width', 790)
}
ss_img.onmouseleave = function () {
    ss_img.style.width = 150 + 'px'
    move(ss_img, 'width', 150)
}

var tab_head = document.getElementsByClassName('tab_head')[0]
var J_specTop_left_bottomS = document.getElementsByClassName('J_specTop_left_bottom')[0].children
var headAs = tab_head.getElementsByTagName('a')
console.log(J_specTop_left_bottomS[1]); for (var i = 0; i < headAs.length; i++) {
    headAs[i].index = i
    headAs[i].onmouseenter = function () {
        var num = this.index
        for (var i = 0; i < headAs.length; i++) {
            J_specTop_left_bottomS[i].style.display = 'none'
        }
        J_specTop_left_bottomS[num].style.display = 'block'
    }
}

// 轮播图
var lbtBox = document.getElementById('lbt_bigbox')
var imgS = lbtBox.children
var oL = lbtBox.nextElementSibling
var prev = oL.nextElementSibling
var next = prev.nextElementSibling
var num = 0
var key = 0
var timer = null
var flag = true

for (var i = 0; i < imgS.length; i++) {
    var liL = document.createElement('li')
    oL.appendChild(liL)
    liL.className = 'dot'
}
var liS = oL.children
light()

for (var i = 0; i < liS.length; i++) {
    liS[i].index = i
    liS[i].onmouseenter = function () {
        if (flag) {
            this.style.cursor = 'pointer'
            num = this.index
            key = this.index
            light()
            img()
        }

    }
}

prev.onclick = function () {
    if (flag == true) {
        num--
        key--
        if (num < 0) {
            num = liS.length - 1
        }
        if (key < 0) {
            key = imgS.length - 1
        }
        light()
        img()
    }
}

next.onclick = function () {
    if (flag) {
        autoplay()
    }
}


window.onload = function () {
    clearInterval(timer)
    timer = setInterval(autoplay, 3000)
}

lbtBox.onmouseenter = function () {
    clearInterval(timer)
}
lbtBox.onmouseleave = function () {
    timer = setInterval(autoplay, 3000)
}

function light() {
    for (var i = 0; i < liS.length; i++) {
        liS[i].className = ''
    }
    liS[num].className = 'dot'
}

function img() {
    flag = false
    for (var i = 0; i < imgS.length; i++) {
        imgS[i].style.opacity = 0
    }
    move(imgS[key], 'opacity', 100, function () {
        flag = true
    })
}

function autoplay() {
    num++
    key++
    if (num > liS.length - 1) {
        num = 0
    }
    if (key > imgS.length - 1) {
        key = 0
    }
    light()
    img()
}
    // console.log(liS);
